package com.itheima.dianming.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.itheima.dianming.pojo.domain.StuProject;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.security.core.parameters.P;

public interface StuProjectMapper extends BaseMapper<StuProject> {
    @Select("<script> SELECT t1.id,t2.`username` AS stuName,\n" +
            "(SELECT project_name FROM tb_project WHERE id =project_id) AS project_name,\n" +
            "t1.git_url,t1.branch_name,t1.path,t1.stu_id,t1.project_id \n" +
            "FROM `tb_stu_project` t1 LEFT JOIN tb_stu  t2 ON t1.`stu_id` = t2.`id`\n" +
            "<where> \n" +
            " <if test='name!=null and name.length()>0 '> and t2.`username` = #{name}   </if> \n" +
            " <if test='projectId!=null '> and t1.`project_id` = #{projectId}   </if> " +
            "</where></script>")
    IPage<StuProject> queryPage(IPage<StuProject> pageInfo,
                                @Param("name") String name,
                                @Param("projectId")Long projectId);
}
